<template>
  <div />
</template>
<script>
import router from '@/router'
export default {
  data() {
    return {
      loading: false
    }
  },
  mounted() {
    const code = this.$route.query.code // getUrlParam('code')
    // console.log("code:"+code);
    // code="071odvVE0Gwlzf2ECpWE0JlfVE0odvVD";
    if (code) {
      // 如果是微信登陆
      // 根据code获取access_token
      // wxlogin(code).then( res=>{
      //   let access_token= res.access_token
      //   let openid= res.openid
      //   console.log('access_token:'+access_token+ 'openid:'+openid)
      // })
      this.loading = true
      this.$store
        .dispatch('user/wxlogin', code)
        .then(() => {
          router.replace({
            path: '/'
          })
          this.loading = false
        })
        .catch(() => {
          this.loading = false
        })
    }
  }
}
</script>
